<template>
	<view id="my">
		<head-navigation  :back-is-show="0" />
		<view class="head">
			<view class="head_info">
				<view class="head_info_l">
					<image :src="customer.avatar == undefined ?'/static/my/my_logo01.png':customer.avatar == ''?'/static/other/logo.png':customer.avatar" mode=""></image>
					<view class="txt_box" v-if="isToken">
						财富值:{{customer.wealth}}
					</view>
				</view>
				<view @click="jumpLogin" class="name_text" v-if="!isToken">点击登录</view>
				<view class="head_info_r" v-else>
					<view class="hir_name">
					  <text class="hir_word ellipseHide_two">{{customer.nickName}}</text>
					  <!-- <image @click="jumpSettings" class="hir_pen" src="/static/my/pen.png" mode=""></image> -->
					</view>
					<!-- <view class="hir_wallet">
						{{customer.phone}}
					</view> -->
					<!-- <view class="wealth_value">财富值: {{customer.wealth}}</view> -->
				</view>
				<view class="head_info_action_b">
					<view class="icon_b"  @click="otherFunctionsJump({id:3})">
						<image src="/static/my/xx.png" mode=""></image>
					</view>
<!-- 					<view class="icon_b" style="margin-left: 30rpx;" @click="otherFunctionsJump({id:8})">
						<image src="/static/my/sz.png" mode=""></image>
					</view> -->
				</view>
			</view>
			<!-- #ifdef H5 -->
			<view class="advertisement" v-if="isToken">
				<image src="https://kayouyou-1257308601.cos.ap-guangzhou.myqcloud.com/c379c2f4656a47318918fdb9175af7d1.png" mode=""  @click="invitation"></image>
			</view>
			<!-- #endif -->
		</view>
		<view class="content">
			<!-- <view class="content_nav">
				<view class="content_nav_box" v-for="(item,index) in navList" :key="index" @click="orderJump(index)">
					<image :src="item.img" mode=""></image>
					<text>{{item.value}}</text>
				</view>
				<image class="split_line" src="../../static/my/split_line.png" mode=""></image>
				<view class="content_nav_box" @click="orderJump">
					<image src="../../static/my/qykdd.png" mode=""></image>
					<text>全部订单</text>
				</view>
			</view> -->
			<view class="common_functions">
				<view class="common_functions_title">常用功能</view>
				<view class="other_function">
					<block v-for="(item,oIndex) in otherFunctionNav" :key="oIndex">
						<view class="other_function_nav"  @click="otherFunctionsJump(item)" v-if="item.isShow">
							<image :src="item.img" mode=""></image>
							<text>{{item.title}}</text>
						</view>
					</block>
					<!-- #ifdef H5-DEV || H5-TEST || WX-DEV || WX-TEST -->
					<view class="other_function_nav" @click="copyToken">
						<image src="/static/my/other_icon_02.png" mode=""></image>
						<text>复制token</text>
					</view>
					 <!-- #endif -->
				</view>
			</view>
			<!-- <view class="common_functions" v-if="marketShow">
				<view class="common_functions_title">积分兑换</view>
				<view class="other_function" style="align-items: flex-start;">
					<view class="other_function_nav" @click="jumpExchange">
						<image src="../../static/my/haihang.png" mode=""></image>
						<text>海南航空</text>
						<text>金鹏积分</text>
					</view>
					<view class="other_function_nav" @click="jumpMarket"  v-if="marketShow">
						<image src="../../static/my/jishi.png" mode=""></image>
						<text>积分集市</text>
					</view>
				</view>
			</view> -->
		</view>
		<!-- 海报 -->
		<invitation-tasks ref="child" ></invitation-tasks>
		<!-- 自定义tabBar -->
		<view style="height: 100rpx;"></view>
		<uni-popup ref="popupLogin" type="dialog" mask-background-color="rgba(0,0,0,0.8)">
			<uni-popup-dialog mode="base" :confirmText="'去登录'" :title="'提示'" :content="'该功能需要登录进行查看'"
				:before-close="true" @close="loginClose" @confirm="loginConfirm"></uni-popup-dialog>
		</uni-popup>
		<uni-popup ref="popupRealName" type="dialog" mask-background-color="rgba(0,0,0,0.8)">
			<uni-popup-dialog mode="base" :confirmText="'去实名'" :title="'您还未实名认证'"
				:content="'本功能涉及数字资产请先进行实名认证'" :before-close="true" @close="realNameClose"
				@confirm="realNameConfirm"></uni-popup-dialog>
		</uni-popup>

	</view>
</template>

<script>
	const app = getApp()
	import {
		wealthInfo,
	} from '@/api/wallet.js'
	import {getOperationConfiguration} from '@/api/api-v1-2.js'
	import { shopCollectNum,myWalletButton,marketPlantButton,getNfrFlag } from '@/api/my.js'
	export default {
		data() {
			return {
				navList:[ //订单nav
					{
						img:'../../static/my/dfk.png',value:'待付款'
					},
					{
						img:'../../static/my/ywc.png',value:'已完成'
					},
					{
						img:'../../static/my/yqx.png',value:'已取消'
					},
				],
				otherFunctionNav:[ //其他功能
					// {
					// 	id:1,img:'../../static/my/other_icon_01.png',title:'积分集市',isShow:false, //是否显示按钮
					// },
					{
						id:2,img:'../../static/my/other_icon_02.png',title:'区块链查询',isShow:false, //是否显示按钮
					},
					{
						id:3,img:'../../static/my/other_icon_03.png',title:'消息通知',isShow:false, //是否显示按钮
					},
					{
						id:4,img:'../../static/my/lxkf.png',title:'联系客服',isShow:true, //是否显示按钮
					},
					{
						id:5,img:'../../static/my/bzzx.png',title:'帮助中心',isShow:true, //是否显示按钮
					},
					{
						id:6,img:'../../static/my/gzgzh.png',title:'关注公众号',isShow:true, //是否显示按钮
					},
					{
						id:9,img:'../../static/my/icon_card.png',title:'历史权益卡',isShow:true, //是否显示按钮
					},
					{
						id:7,img:'../../static/my/gywm.png',title:'关于我们',isShow:true, //是否显示按钮
					},
					{
						id:8,img:'../../static/my/sz.png',title:'设置',isShow:true, //是否显示按钮
					},
				],
				customer:{},//用户信息
				isToken:false, // 判断是否登录
				mainImageUrl: this.mainImageUrl,
				wealthNum: 0,//财富值
				marketShow: false,//是否显示集市
			}
		},
		onLoad() {
			// #ifdef H5
				this.otherFunctionNav[0].isShow = true
			// #endif
		},
		onShow() {
			this.isToken = (this.$queue.getData('token') != undefined && this.$queue.getData('token') != '') ? true : false
			if (this.isToken) {
				this.getCustomer() //用户信息
				this.getNfrFlagFunc()
				// this.getWealthInfo()
			}
			this.getDonationShow()
		},
		onHide() {
			// this.$nextTick(()=>{
			// 	uni.showTabBar()
			// })
		},
		methods: {
			//获取是否有历史卡标识
			async getNfrFlagFunc() {
				var res = await getNfrFlag() 
				var index = this.otherFunctionNav.findIndex(obj => obj.id == 9)
				// 历史卡标识 1不显示 2显示
				 this.otherFunctionNav[index].isShow = res.result
			},
			// 获取钱包信息
			async getWealthInfo() {
				var res = await wealthInfo()
				this.wealthNum = res.result.wealth
			},
			// 获取用户信息
			async getCustomer() {
				var res = await this.$api.getCustomer()
				this.customer = res.data
			},
			// 复制 token
			copyToken() {
				var data = uni.getStorageSync('token')
				if(data == undefined || data == ''){
					uni.showToast({
					  title: 'token不能为空',
					  icon: 'none'
					})
				}else{
					var _this = this
					_this.$copyTxt(data).then(
						res => {
							uni.showToast({
								title: '复制成功',
								icon: 'none'
							})
						}
					)
				}
			
			},
			loginConfirm() {
				// var url = '/pages/index/shenye-paradise/paradise-details/paradise-details?id=' + this.id
				app.jumpPublicLogin()
			},
			loginClose() {
				this.$refs.popupLogin.close()
			},
			realNameConfirm() {
			   this.realNameClose()
			   app.jumpPublicRealName()
			},
			realNameClose() {
				this.loginClose()
				this.$refs.popupRealName.close()
			},
			// 跳转登录验证
			jumpLogin(){
				app.jumpPublicLogin()
			},
			// 跳转实名验证
			jumpRealName(){
				app.jumpPublicRealName()
			},
			orderJump(index){ //订单跳转
				if(!this.isToken){
				   this.$refs.popupLogin.open()
				   return 
				}
				var headerIndex = 0
				if(index==0){ //待付款
					headerIndex = 1
				}else if(index==1){ //已完成
					headerIndex = 3
				}else if(index==2){ //已取消
					headerIndex = 5
				}else{ //权益卡订单
					headerIndex = 0
				}
				uni.navigateTo({
					url:'/pages/subPackages/pagesC/order/order?headerIndex=' + headerIndex
				})
			},
			//打开邀请码
			invitation() {
				// if(!this.customer.isRealName){
				//    this.$refs.popupRealName.open()
				//    return 
				// }
				this.$refs.child.open();
			},
			async getDonationShow() { // 按钮显示隐藏  1不显示 2显示
				var res = await getOperationConfiguration()
				var vo = await marketPlantButton() //神椰集市 、神椰工厂按钮
				var el = res.result
				var bStatus = vo.result
				// 神椰集市是否显示 1不显示 2显示
				if(bStatus.market && el.commodityValue == 2) {
					 // this.otherFunctionNav[0].isShow = true
					 this.marketShow = true
				}else{
					this.marketShow = false
					 // this.otherFunctionNav[0].isShow = false
				} 
			},
			// 跳转设置
			jumpSettings(){
				uni.navigateTo({
					url: '/pages/subPackages/pagesC/setUp/setUp'
				})
			},
			otherFunctionsJump(item){ //其他功能跳转
				if(!this.isToken && (item.id == 1 || item.id == 3 || item.id == 8)){
				   this.$refs.popupLogin.open()
				   return 
				}
				if(item.id == 1){ //神椰集市
					uni.navigateTo({ 
						url: "/pages/subPackages/pagesB/shenyeMarket/shenyeMarket"
					})
				}else if(item.id == 2){ //区块链信息查询
					// #ifdef H5
					window.location.href = 'https://ddc.bsnbase.com/main/ddc-querys/query'
					// #endif
					// #ifdef MP-WEIXIN
					uni.navigateTo({
						url:"/pages/subPackages/pagesD/webView/webView?url=https://ddc.bsnbase.com/main/ddc-querys/query"
					})
					// #endif
				}else if(item.id == 3){ //消息通知
					uni.navigateTo({
						url: "/pages/subPackages/pagesC/news/news"
					})
				}else if(item.id == 4){ //联系客服
					uni.navigateTo({
						url: "/pages/subPackages/pagesC/customerService/customerService"
					})
				}else if(item.id == 6){ //关注公众号
					uni.navigateTo({
						url:'/pages/subPackages/pagesC/followOfficialAccount/followOfficialAccount'
					})
				}else if(item.id == 7){ //关于我们
					uni.navigateTo({
						url:'/pages/subPackages/pagesC/about/about'
					})
				}else if(item.id == 5){ //帮助中心
					uni.navigateTo({
						url:'/pages/subPackages/pagesC/help/help'
					})
				}else if(item.id == 8){ //设置
					uni.navigateTo({
						url: "/pages/subPackages/pagesC/setUp/setUp"
					})
				}else if(item.id == 9){ //历史权益卡
					uni.navigateTo({
						url: "/pages/subPackages/pagesB/equityNfr/equityNfr"
					})
				}
			},
			//积分兑换跳转
			jumpExchange(){
				if(!this.isToken){
				   this.$refs.popupLogin.open()
				   return 
				}
				uni.navigateTo({
					url:'/pages/subPackages/pagesC/haihang/integralExchange'
				})
			},
			//积分集市
			jumpMarket(){
				if(!this.isToken){
				   this.$refs.popupLogin.open()
				   return 
				}
				uni.navigateTo({
					url: "/pages/subPackages/pagesB/shenyeMarket/shenyeMarket"
				})
			},
		}
	}
</script>

<style scoped>

	#my {
		background: #F2F5F8 url('https://kayouyou-1257308601.cos.ap-guangzhou.myqcloud.com/4d09bb68c8874ec694cabb45d827fb3f.png') no-repeat; 
		background-size: 100% 492rpx;
		/* background: linear-gradient(179.95deg, #FFFFFF 0.04%, rgba(255, 255, 255, 0) 50%); */
		min-height: 100vh	
	}
	
	view{
		box-sizing: border-box;
	}
	
	.head{
		width: 750rpx;
		/* height: 324rpx; */
	}
	.head_info{
		position: relative;
		display: flex;
		flex-direction: row;
		align-items: center;
		width: 750rpx;
		box-sizing: border-box;
		padding: 10rpx 48rpx 62rpx 40rpx;
	}
	.head_info_l{
		position: relative;
		display: flex;
		flex-direction: column;
		align-items: center;
		height: 144rpx;
		margin-right: 28rpx;
		border-radius: 50%;
	}
	.head_info_l image{
		width: 120rpx;
		height: 120rpx;
		border: 4rpx solid #fff;
		border-radius: 50%;
	}
	.head_info_l .txt_box{
		min-width: 170rpx;
		margin-top: -32rpx;
		padding: 0 10rpx;
		height: 48rpx;
		border-radius: 100rpx;
		border: 4rpx solid #fff;
		line-height: 40rpx;
		background: #FF8B8B;
		font-size: 26rpx;
		color: #fff;
		text-align: center;
	}
	.head_info_r{
		flex: 1;
	}
	.head_info_action_b{
		position: absolute;
		top: 10rpx;
		right: 20rpx;
		display: flex;
		justify-content: flex-start;
		align-items: center;
	}
	.head_info_action_b .icon_b{
		width: 40rpx;
		height: 40rpx;
		
	}
	.head_info_action_b .icon_b image{
		width: 40rpx;
		height: 40rpx;
	}
	.hir_name{
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	.real_name{
		padding: 4rpx 12rpx;
		border-radius: 100rpx;
		background: linear-gradient(90deg, #B948FF 0%, #6461FF 98.24%);
		font-size: 20rpx;
		color: #FFFFFF;
		margin-left: 40rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.name_text{
		font-size: 34rpx;
		font-weight: bold;
	}
	.hir_word{
		max-width: 400rpx;
		font-size: 34rpx;
		font-weight: bold;
	}
	.hir_pen{
		width: 30rpx;
		height: 30rpx;
		margin-left: 28rpx;
	}
	.hir_wallet{
		display: flex;
		flex-direction: row;
		width: 100%;
		font-size: 26rpx;
		line-height: 36rpx;
		margin-top: 10rpx;
		color: #222222;
	}
	.wealth_value{
		height: 44rpx;
		border-radius: 8rpx;
		padding: 0rpx 10rpx;
		line-height: 40rpx;
		border: 2rpx solid #A60F0B80;
		color: #A60F0B;
		font-size: 26rpx;
		display: inline-flex;
		margin-top: 8rpx;
	}
	.hir_address{
		flex: 1;
		width: 0;
	}
	.hir_copy{
		width: 32rpx;
		height: 30rpx;
		margin-left: 40rpx;
	}
	/* 邀请 */
	.advertisement{
		width: 710rpx;
		height: 98rpx;
		margin: 0 auto;
		margin-bottom: 40rpx;
	}
	.advertisement image{
		width: 100%;
		height: 100%;
	}
	/* end */
	.content{
		position: relative;
		display: flex;
		flex-direction: column;
		align-items: center;
		
	}
	.content_nav{
		display: flex;
		align-items: center;
		width: 710rpx;
		height: 166rpx;
		border-radius: 16rpx;
		background-color: #FFFFFF;
		margin-bottom: 24rpx;
	}
	.content_nav_box{
		width: 25%;
		display: flex;
		flex-direction: column;
		align-items: center;
		font-size: 28rpx;
		color: #222222;
	}
	.content_nav_box image{
		width: 52rpx;
		height: 52rpx;
		margin-bottom: 5rpx;
	}
	.split_line{
		width: 9rpx;
		height: 86rpx;
	}
	.common_functions{
		width: 710rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		padding: 34rpx 20rpx 10rpx;
		margin-bottom: 30rpx;
	}
	.common_functions_title{
		font-size: 32rpx;
		color: #2C2A2F;
		margin-left: 12rpx;
		font-weight: bold;
	}
	.common_functions_nav{
		display: flex;
		align-items: center;
		justify-content: space-between;
		border-bottom: 2rpx solid #E7E7E7;
		padding: 32rpx 10rpx;
	}
	.common_functions_nav:last-child{
		border-bottom: 0;
	}
	.common_functions_nav_l{
		display: flex;
		align-items: center;
		flex-direction: row;
		font-size: 28rpx;
		color: #2C2A2F;
		position: relative;
	}
	.c_title{
		position: relative;
	}
	.c_tip_word{
		position: absolute;
		top: -4rpx;
		left: 104rpx;
		font-family: PingFang SC;
		font-size: 16rpx;
		font-weight: 400;
		/* line-height: 22rpx; */
		letter-spacing: 0rpx;
		color: #FFFFFF;
		padding: 2rpx 6rpx;
		min-width: 20rpx;
		min-height: 20rpx;
		width: fit-content;
		background: #EE3225;
		border-radius: 200rpx;
	}
	.red_dot{
		width: 16rpx;
		height: 16rpx;
		background-color: #EE3225;
		border-radius: 50%;
		position: absolute;
		top: 0;
		left: 28rpx;
		z-index: 1;
	}
	.common_functions_nav_l image{
		width: 44rpx;
		height: 44rpx;
		margin-right: 18rpx;
	}
	.common_functions_nav_r{
		font-size: 26rpx;
		color: #9F9F9F;
	}
	.common_functions_nav_r image{
		width: 22rpx;
		height: 20rpx;
		margin-left: 10rpx;
	}
	.other_function{
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		padding: 10rpx 0 34rpx;
	}
	.other_function_nav{
		display: flex;
		flex-direction: column;
		align-items: center;
		font-size: 26rpx;
		color: #222222;
		width: 25%;
		padding-top: 30rpx;
	}
/* 	.other_function_nav:nth-child(5){
		margin-top: 40rpx;
	} */
	.other_function image{
		width: 56rpx;
		height: 56rpx;
		margin-bottom: 8rpx;
	}
	
	.other_function2{
		display: flex;
		flex-wrap: wrap;
		padding: 10rpx 0 34rpx;
	}
</style>
